<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    ul :first-child {
      background-color: red;
    }
    ul :last-child {
      background-color: red;
    }

    ul :nth-child(3) {
      background-color: green;
    }
  </style>
  <body>
    <ul>
      <li>我是第1个</li>
      <li>我是第2个</li>
      <li>我是第3个</li>
      <li>我是第4个</li>
      <li>我是第5个</li>
      <li>我是第6个</li>
      <li>我是第7个</li>
      <li>我是第8个</li>
    </ul>
  </body>
</html>
